package 数列.解压缩编码列表;

import java.util.Arrays;

/**
 * TODO
 *
 * @className: jysbmlb
 * @description: TODO
 * @author: 等什么柠檬君
 * @date: 2022-04-27 21:30
 **/
public class jysbmlb {
    public static void main(String[] args) {
      int[]  nums = {1,2,3,4};
      System.out.println(Arrays.toString(decompressRLElist(nums)));
    }

    public static int[] decompressRLElist(int[] nums) {
        int result[];
        int length = 0;
        for(int i = 0; i < nums.length-1; ++i){
            if ((i & 1) == 0){
                length += nums[i];
            }
        }
        result = new int[length];
        int index = 0;
        for(int i = 0; i < nums.length-1; ++i){
            if ((i & 1) == 0){
                for(int j = 0; j < nums[i]; ++j ){
                    result[index] = nums[i+1];
                    index++;
                }
            }
        }
        return result;
    }
}
